package errormsg

const (
	SUCCESS = 200
	ERROR   = 500
	//  1000开头的错误和用户相关
	ERROR_USERNAME_USED    = 1001
	ERROR_USER_NOT_EXIST   = 1002
	ERROR_PASSWORD_WRONG   = 1003
	ERROR_TOKEN_WRONG      = 1004
	ERROR_TOKEN_NOT_EXIST  = 1005
	ERROR_TOKEN_RUNTIME    = 1006
	ERROR_TOKEN_TYPE_WRONG = 1007
	ERROR_USER_NOT_RIGHT   = 1008
	//2000开头的错误和文章相关
	ERROR_ARTICLE_NOT_EXIST = 2001
	//3000开头的错误和分类相关
	ERROR_CATENAME_USED  = 3001
	ERROR_CATE_NOT_EXIST = 3002
)

var codeMsg = map[int]string{
	SUCCESS:                "success",
	ERROR:                  "fail",
	ERROR_USERNAME_USED:    "用户名已存在",
	ERROR_USER_NOT_EXIST:   "该用户不存在",
	ERROR_PASSWORD_WRONG:   "密码错误",
	ERROR_TOKEN_WRONG:      "TOKEN错误",
	ERROR_TOKEN_NOT_EXIST:  "TOKEN不存在",
	ERROR_TOKEN_RUNTIME:    "TOKEN已失效",
	ERROR_TOKEN_TYPE_WRONG: "TOKEN类型错误",
	ERROR_USER_NOT_RIGHT:   "用户类型错误",

	ERROR_CATENAME_USED:  "分类名称已经存在",
	ERROR_CATE_NOT_EXIST: "分类不存在",

	ERROR_ARTICLE_NOT_EXIST: "文章不存在",
}

func GetErrorMsg(code int) string {

	return codeMsg[code]
}
